
#include "../../extream/Overset/include/box.hpp"
#include "../myTime.hpp"
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;
using namespace EXTREAM;

// mpic++ arr_vs_ptr_arr.cpp -I /usr/local/cgnsParallel/include

int main() {
  const int num = 1000000;
  vector<Box> vec(num);
  Box *vec_ptr = vec.data();

  //   vec_ptr[0] = Box{1, 2, 3, 4, 5, 6};
  MyTimer(0, "vector");
  for (int i = 0; i < num; ++i) {
    vec_ptr[i] = Box{i, i + 1, i + 2, i + 3, i + 4, i + 5};
  }
  MyTimer(1, "");

  vector<Box> v2(num);
  vector<Box *> bptr(num);
  for(int i = 0; i < num; ++i)
    bptr[i] = &v2[i];
  Box **bpptr = bptr.data();
  MyTimer(0, "pointer");
  for (int i = 0; i < num; ++i) {
    *bpptr[i] = Box{i, i + 1, i + 2, i + 3, i + 4, i + 5};
  }
  MyTimer(1, "");

  return 0;
}